﻿namespace GSC.WebControls
{
    using System;
    using System.Collections.Generic;
    using System.Web.UI.Design;
    using System.Web.UI.Design.WebControls;
    using System.ComponentModel;
    using System.Web.UI;
    using System.Web;
    using System.Web.UI.WebControls;
    using System.IO;
    using System.ComponentModel.Design;
    using System.Web.UI.HtmlControls;
    sealed class BackgroundCenterLeftMenuTitleControlDesigner : ControlDesigner
    {
        private BackgroundCenterLeftMenuTitleControl _leftMenuTitle;
        /// <summary>
        /// </summary>
        /// <param name="Component"></param>
        public override void Initialize(IComponent Component)
        {
            base.Initialize(Component);
            this._leftMenuTitle = (BackgroundCenterLeftMenuTitleControl)Component;
        }
        bool _isComponentChanged = false;
        public override void OnComponentChanged(object sender, ComponentChangedEventArgs ce)
        {
            base.OnComponentChanged(sender, ce);
            if (!this._isComponentChanged)
            {
                switch (ce.Member.Name)
                {
                    case "IsExpanded":
                        this._isComponentChanged = true;
                        if (this._leftMenuTitle.Parent is BackgroundCenterLeftMenuControl)
                        {
                            if (((BackgroundCenterLeftMenuControl)this._leftMenuTitle.Parent).MultiLine)
                            {

                            }
                            else
                            {
                                bool isChanged = false;
                                foreach (BackgroundCenterLeftMenuTitleControl item in ((BackgroundCenterLeftMenuControl)this._leftMenuTitle.Parent).Titles)
                                {
                                    if (item.IsExpanded && !isChanged)
                                    {
                                        isChanged = true;
                                    }
                                    else
                                    {
                                        item.IsExpanded = false;
                                    }
                                }
                            }
                        }
                        else
                        {

                        }
                        break;
                }
                this._isComponentChanged = false;
            }
        }

        public override void OnComponentChanging(object sender, ComponentChangingEventArgs ce)
        {
            base.OnComponentChanging(sender, ce);
        }
    }
}
